#!/usr/bin/env python

from vcs import VCS
import os

class Hg ( VCS ):
	def __init__ ( self, repo_name ):
		self._repo = repo_name
		self._dir  = os.path.basename ( self._repo )

	def clone ( self ):
		os.popen ( "hg clone %s" % self._repo )

	def version ( self ):
		curdir = os.getcwd ()
		os.chdir ( self._dir )
		version = os.popen ( 'hg tip --template {rev}' ).read ().strip ()
		os.chdir ( curdir )

		return version
